{% extends "common/layout_main.html" %}
{% block content %}
<div class="row  border-bottom">
    <div class="col-lg-12">
        <div class="tab_title">
            <ul class="nav nav-pills">
                <li class="current">
                    <a href="{{ url_for('member_page.index') }}">会员列表</a>
                </li>
                <li>
                    <a href="{{ url_for('member_page.comment') }}">会员评论</a>
                </li>
            </ul>
        </div>
    </div>
</div>
<div class="row mg-t20 wrap_member_edit">
	<div class="col-lg-12">
		<h2 class="text-center">会员设置</h2>
		<div class="form-horizontal m-t">
			<div class="hr-line-dashed"></div>
			<div class="form-group">
				<label class="col-lg-2 control-label">会员昵称:</label>
				<div class="col-lg-10">
					<input type="text" class="form-control" placeholder="请输入会员名称" name="nickname" value="{{ member.nickname }}">
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<div class="form-group">
				<div class="col-lg-4 col-lg-offset-2">
					<input type="hidden" name="id" value="0">
					<button class="btn btn-w-m btn-outline btn-primary save">保存</button>
				</div>
			</div>
		</div>
	</div>
</div>
{% endblock %}
{% block js %}
<script>
	var member_edit = {
		init:function(){
			this.eventBind()
		},
		eventBind:function(){
            $(".wrap_member_edit .save").click(function(){
                var nickname_target = $(".wrap_member_edit input[name=nickname]");
                var nickname = nickname_target.val();
                if (nickname == "" || nickname.length < 1){
                    common_ops.tip("请输入正确的昵称！",nickname_target)
                    return ;
                }

                $.ajax({
                    url:"/member/edit?id={{ member.id }}",
                    type:"POST",
                    data:{"nickname":nickname},
                    dataType:"json",
                    success:function(res){
                        var callback = null
                        if(res.code == 200){
                            callback = function(){
                                window.location.href = "/member/index"
                            }
                            common_ops.alert(res.msg,callback)
                        }
                        if(res.code == -1){
                            common_ops.alert(res.msg)
                        }
                    }
                })

            });
		}
	}
    $(document).ready(function(){
        member_edit.init();
    })

</script>
{% endblock %}
